home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Speccy ClassiX 1998
/
Speccy ClassiX 98.iso
/
amiga_system
/
the_aminet
/
dev
/
gcc
/
ixemulsrc.lha
/
ixemul-41.4
/
library
/
getcrap.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-27
|
4KB
|
180 lines
/*
* This file is part of ixemul.library for the Amiga.
* Copyright (C) 1991, 1992 Markus M. Wild
* Portions Copyright (C) 1994 Rafael W. Luebbert
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: getcrap.c,v 1.2 1994/06/19 14:04:21 rluebbert Exp $
*
* $Log: getcrap.c,v $
* Revision 1.2 1994/06/19 14:04:21 rluebbert
* Appeasing HWGRCS
*
* Revision 1.1 1994/06/19 14:02:22 rluebbert
* Initial revision
*
*
*/
/* stubs for group-file access functions */
#define KERNEL
#include "ixemul.h"
#include "kprintf.h"
#include <stdlib.h>
int
getpid()
{
return (int) FindTask (0);
}
int
getpgrp(int pid)
{
/* this could change later.. but we'll see .. */
return pid ? pid : (int) FindTask(0);
}
int
getgroups(int gidsetlen, int *gidset)
{
/* we return 1 group, group 0 (you really ARE root on the amiga:-)) */
if (gidsetlen >= 1)
{
*gidset = 0;
return 1;
}
errno = EINVAL;
KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
return -1;
}
int
getrusage (int who, struct rusage *rusage)
{
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
{
errno = EINVAL;
KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
return -1;
}
*rusage = (who == RUSAGE_SELF) ? u.u_ru : u.u_cru;
return 0;
}
#include <grp.h>
struct group *
getgrgid (gid_t gid)
{
static char *end = 0;
static struct group grp = { "amiga", "*", 0, & end };
return &grp;
}
struct group *
getgrnam (const char *name)
{
static char *end = 0;
static struct group grp = { "amiga", "*", 0, & end };
return &grp;
}
#include <pwd.h>
struct passwd *
getpwuid (uid_t uid)
{
char *home = getenv("HOME");
char *user = getenv("USER");
static struct passwd pw = { NULL, /* pw_name */
"*", /* pw_passwd */
0, /* pw_uid */
0, /* pw_gid */
0, /* pw_change */
0, /* pw_class */
"amiga user", /* pw_gecos */
NULL, /* pw_dir */
"/bin/sh", /* pw_shell */
0}; /* pw_expire */
/* see getpwnam() */
if (home)
pw.pw_dir = home;
else
pw.pw_dir = "/sys";
if (user)
pw.pw_name = user;
else
pw.pw_name = "amiga";
pw.pw_uid = uid;
return &pw;
}
struct passwd *
getpwnam (const char *name)
{
char *home;
static struct passwd pw = { 0, /* pw_name */
"*", /* pw_passwd */
0, /* pw_uid */
0, /* pw_gid */
0, /* pw_change */
0, /* pw_class */
"amiga user", /* pw_gecos */
NULL, /* pw_dir */
"/bin/sh", /* pw_shell */
0}; /* pw_expire */
/* this is not quite safe, since this library function could be called
* in parallel with different names.. well, I don't consider this worth
* doing `right', it's here to be able to link some programs ;-) */
pw.pw_name = (char *) name;
if (home = getenv("HOME"))
pw.pw_dir = home;
else
pw.pw_dir = "/sys";
return &pw;
}
static char hostname[255] = "amiga";
int
gethostname (char *name, int namelen)
{
strncpy (name, hostname, namelen);
return 0;
}
int
sethostname (char *name, int namelen)
{
int len = namelen < sizeof (hostname) - 1 ? namelen : sizeof (hostname) - 1;
strncpy (hostname, name, len);
hostname[len] = 0;
return 0;
}